<template>
  <div class="elevator__module">
    <template v-for="{title, toScroll} in value">
      <div :key="title" @click="toScrollHandler(toScroll)" class="elevator__item" v-text="title" />
    </template>
    <div @click="toScrollHandler(0)" class="elevator__item">
      <i class="to-top__item iconfont icon-fanhuidingbu" />
    </div>
  </div>
</template>

<script>

export default {
    name: 'ElevatorModule',
    props: {
        value: {
            type: Array,
            default: () => [],
        },
    },
    methods: {
        toScrollHandler(toScroll = 0) {
            window.scroll({ top: toScroll, behavior: 'smooth' });
        },
    },
};
</script>

<style lang="less">
.elevator__module {
  width: 50px;
  line-height: 50px;
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 10;
  transform: translateY(-50%);
  border-radius: 4px 0 0 4px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
  background: #fff;
  overflow: hidden;
  user-select: none;
  font-size: 16px;
  text-align: center;

  .elevator__item {
    width: 50px;
    height: 50px;
    position: relative;
    overflow: hidden;
    color: #817487;

    &:hover:before {
      transform: translateX(0);
    }

    &::before {
      content: "";
      width: 100%;
      height: 100%;
      display: block;
      position: absolute;
      top: 0;
      left: 0;
      z-index: -1;
      transform: translateX(100%);
      transition: all 0.3s;
      background-color: @base_color_2;
      pointer-events: none;
    }

    &:last-child::before {
      background-color: #f5e0a0;
    }

    .to-top__item {
      width: 50px;
      height: 50px;
      position: absolute;
      top: 0;
      left: 0;
      font-size: 25px;
      color: @base_color;
    }
  }
}
</style>
